home *** CD-ROM | disk | FTP | other *** search
/ Freelog 100 / FreelogNo100-NovembreDecembre2010.iso / ViePratique / Calendar Magic / setup.exe / {app} / Quadratic.shf < prev    next >
Text File  |  2007-01-06  |  720b  |  24 lines

  1. Degrees
  2. ' Quadratic Equation Solver
  3. '
  4. ' Finds real or complex roots of the equation a*x^2 + b*x + c = 0.
  5. ' Coefficients a, b, c must be real numbers. a must be non-zero and at least one of b and c also non-zero.
  6. ' First root has real and imaginary parts Rx1 and Ix1 respectively. Second root is similarly defined.
  7. '
  8. a = 1
  9. ==> a = 1
  10. b = 2
  11. ==> b = 2
  12. c = 3
  13. ==> c = 3
  14. D = b ^ 2 - 4 * a * c
  15. ==> D = -8
  16. Rx1 = -b / (2 * a) - (1 + sign(D)) * sign(b) * sqrt(abs(D)) / (4 * a) + invert(b) * sqrt((1 - sign(c)) * abs(c / (2 * a)))
  17. ==> Rx1 = -1
  18. Ix1 = (1 - sign(D)) * sqrt(abs(D)) / (4 * a)
  19. ==> Ix1 = 1.4142135623731
  20. Rx2 = c * Rx1 / (a * (Rx1 ^ 2 + Ix1 ^ 2))
  21. ==> Rx2 = -1
  22. Ix2 = -Ix1
  23. ==> Ix2 = -1.4142135623731
  24.